<!--
  author: tangcheng_cd
  create by: 2018/7/5
  descr: Web可视化埋点
-->
<template>
  <div id="webBurialPointTab">
    <div class="input-panel">
      <el-input v-model="url" placeholder="请输入URL地址 http://xxxx 或者 https://xxxx" clearable @keyup.enter.native="enterBurialPointMode"></el-input>
      <el-button type="primary" @click="enterBurialPointMode">进入定义模式</el-button>
      <a id="aUrl" :href="url+'?sensorsdata_visual_mode_in'" target="_blank"></a>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
export default {
  name: 'web-burial-point-tab',
  data () {
    return {
      url: null
    }
  },
  methods: {
    checkUrl () { // 验证URL
      // 先做个简单的验证
      if (this.url === null || this.url === '') {
        return false
      }
      if ((!this.url.toUpperCase().startsWith('HTTP:')) &&
        (!this.url.toUpperCase().startsWith('HTTPS:'))) {
        return false
      }
      // 可以做一些加强版验证
      return true
    },
    enterBurialPointMode () {
      if (!this.checkUrl()) return
      document.getElementById('aUrl').click()
    }
  }
}
</script>

<style lang="stylus" rel="stylesheet/stylus">
#webBurialPointTab
  .input-panel
    padding 30px 20px
    text-align center
    .el-input
      width 66.66%
      .el-input__inner
        height 40px
</style>
